import { defineStore } from 'pinia'
import i18n from '@/languages'

const useLocaleStore = defineStore({
  id: 'locale',
  state: () => {
    return {
      locale: localStorage.getItem('locale') || 'zh'
    }
  },
  actions: {
    setLocale(lang: any) {
      this.locale = lang
      i18n.global.locale.value = lang
      localStorage.setItem('locale', lang)
    }
  }
})

export default useLocaleStore
